<template>
	<view class="i-calendar-item__weeks-box" :class="{
		'i-calendar-item--disable':weeks.disable,
		'i-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
		'i-calendar-item--checked':(calendar.fullDate === weeks.fullDate && !weeks.isDay) ,
		'i-calendar-item--multiple': weeks.multiple,
		'selected': selected && weeks.extraInfo && weeks.extraInfo.info,
		}" @click="choiceDate(weeks)">
		<view class="i-calendar-item__weeks-box-item">
			<text v-if="selected&&weeks.extraInfo" class="i-calendar-item__weeks-box-circle" :class="{
				'blue': weeks.extraInfo.cinfo == 'blue',
				'dark-blue': weeks.extraInfo.cinfo == 'dark-blue',
				'light-blue': weeks.extraInfo.cinfo == 'light-blue',
				'red': weeks.extraInfo.cinfo == 'red',
			}"></text>
			<text class="i-calendar-item__weeks-box-text" :class="{
				'i-calendar-item--isDay-text': weeks.isDay,
				'i-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
				'i-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
				'i-calendar-item--multiple': weeks.multiple,
				'i-calendar-item--disable':weeks.disable,
				}">{{weeks.date}}</text>
			<text v-if="!lunar&&!weeks.extraInfo && weeks.isDay" class="i-calendar-item__weeks-lunar-text" :class="{
				'i-calendar-item--isDay-text':weeks.isDay,
				'i-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
				'i-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
				'i-calendar-item--multiple': weeks.multiple,
				}">今天</text>
			<text v-if="lunar&&!weeks.extraInfo" class="i-calendar-item__weeks-lunar-text" :class="{
				'i-calendar-item--isDay-text':weeks.isDay,
				'i-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
				'i-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
				'i-calendar-item--multiple': weeks.multiple,
				'i-calendar-item--disable':weeks.disable,
				}">{{weeks.isDay?'今天': (weeks.lunar.IDayCn === '初一'?weeks.lunar.IMonthCn:weeks.lunar.IDayCn)}}</text>
			<text v-if="weeks.extraInfo&&weeks.extraInfo.info" class="i-calendar-item__weeks-lunar-text" :class="{
				'i-calendar-item--extra':weeks.extraInfo.info,
				'i-calendar-item--isDay-text':weeks.isDay,
				'i-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
				'i-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
				'i-calendar-item--multiple': weeks.multiple,
				'i-calendar-item--disable':weeks.disable,
				}">{{weeks.extraInfo.info}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			weeks: {
				type: Object,
				default () {
					return {}
				}
			},
			calendar: {
				type: Object,
				default: () => {
					return {}
				}
			},
			selected: {
				type: Array,
				default: () => {
					return []
				}
			},
			lunar: {
				type: Boolean,
				default: false
			}
		},
		methods: {
			choiceDate(weeks) {
				this.$emit('change', weeks)
			}
		}
	}
</script>

<style scoped>
	.i-calendar-item__weeks-box {
		flex: 1;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.i-calendar-item__weeks-box-text {
		font-size: 28rpx;
		color: #333;
	}

	.i-calendar-item__weeks-lunar-text {
		font-size: 24rpx;
		color: #333;
	}

	.i-calendar-item__weeks-box-item {
		position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
		/* width: 100rpx; */
		height: 100rpx;
	}

	.i-calendar-item__weeks-box-circle {
		position: absolute;
		top: 5px;
		right: 5px;
		width: 8px;
		height: 8px;
		border-radius: 8px;
		background-color: #dd524d;

	}

	.i-calendar-item--disable {
		background-color: rgba(249, 249, 249, 0.3);
		color: #c0c0c0;
	}

	.i-calendar-item--isDay-text {
		color: #007aff;
	}

	.i-calendar-item--isDay {
		background-color: #007aff;
		opacity: 0.8;
		color: #fff;
	}

	.i-calendar-item--extra {
		color: #dd524d;
		opacity: 0.8;
	}

	.i-calendar-item--checked {
		background-color: #007aff;
		color: #fff;
		opacity: 0.8;
	}

	.i-calendar-item--multiple {
		background-color: #007aff;
		color: #fff;
		opacity: 0.8;
	}

	.i-calendar-item--checked,
	.i-calendar-item--isDay {
		width: 35px;
		height: 35px;
		border-radius: 50%;
		display: flex;
		justify-content: center;
		align-items: center;
		position: absolute;
		left: 50%;
		top: 50%;
		transform: translate(-50%,-50%);
	}
	.i-calendar-item--checked .i-calendar-item__weeks-box-circle.red,
	.i-calendar-item--checked .i-calendar-item__weeks-box-circle.blue,
	.i-calendar-item--isDay .i-calendar-item__weeks-box-circle.red,
	.i-calendar-item--isDay .i-calendar-item__weeks-box-circle.blue
	{
		top: 25px;
		z-index: 1;
	}

	.i-calendar-item__weeks-box-circle.blue {
		background: #03a9f4;
    top: 35px;
    right: calc(50% - 4px);
	}
	.i-calendar-item__weeks-box-circle.red {
		background: #f44336;
    top: 35px;
    right: calc(50% - 4px);
	}
	.i-calendar-item__weeks-box-circle.dark-blue,
	.i-calendar-item__weeks-box-circle.light-blue
	{
		width: 35px;
		height: 35px;
		border-radius: 50%;
		position: absolute;
		left: 50%;
		top: 50%;
		transform: translate(-50%,-50%);
	}
	.i-calendar-item__weeks-box-circle.dark-blue {
		background: #03a9f4;
	}
	.i-calendar-item__weeks-box-circle.light-blue {
		background: #b3e5fc;
	}
	.i-calendar-item__weeks-box-circle.dark-blue+.i-calendar-item__weeks-box-text
	{
		color: #fff;
	}
	.i-calendar-item__weeks-box-text {
		position: relative;
	}
</style>